import actionType from "../actions";
let initState = { list: [] };

let userReducer = (state = initState, action: any) => {
  switch (action.type) {
    case actionType.LOGIN: //登陆
      return { list: action.playload };
    case actionType.USERLIST: //查询
      return { list: action.playload };
    case actionType.DELUSERBYID: //删除
      return { list: state.list.filter((item: any) => item.id != action.playload) };
    case actionType.ADDUSER: //新增
      return { list: [...state.list, action.playload] };
  }
  return state;
};
export default userReducer;
